#ifndef GENERATOR_H
#define GENERATOR_H

#include <stdio.h>
#include <QAudioFormat>
#include <QIODevice>
#include <QAudioFormat>
#include <QByteArray>
#include <QDebug>
#include <QFile>
#include <QtCore/qmath.h>
#include <QtCore/qendian.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include <QDebug>

using namespace std;

class Generator : public QIODevice
{
    Q_OBJECT
public:
//    Generator(const QAudioFormat &format, qint64 durationUs, int frequency,
//    		float amp_level, QObject *parent);
    Generator(const QAudioFormat &format, qint64 durationUs, int _freq1,
            int _amp1, int _freq2, int _amp2, QObject *parent);
    ~Generator();

    void start();
    void stop();
//    void set_volume(float vol);
//    int set_vol_db(int vol_db);
    vector<double> ydata1;
    vector<double> ydata2;

    int amp1, amp2;
    int freq1, freq2;
    qint64 readData(char *data, qint64 maxlen);
    qint64 writeData(const char *data, qint64 len);
    qint64 bytesAvailable() const;
    QByteArray m_buffer;
    QAudioFormat m_format;


private:
//    void generateData(const QAudioFormat &format, qint64 durationUs, int frequency);
    void generateData(const QAudioFormat &format, qint64 durationUs);

private:
    qint64 m_pos;

};

#endif // GENERATOR_H
